//
//  LXInsuranceTableViewCell.m
//  ZuLinProject
//
//  Created by bancheng on 2021/12/22.
//  Copyright © 2021 LX_App. All rights reserved.
//

#import "LXInsuranceTableViewCell.h"
#import "LXInsuranceModel.h"
#import "LXRepairModel.h"
#import "LXYearCheckModel.h"
#import "LXMainTainModel.h"
@implementation LXInsuranceTableViewCell

// 保险记录
- (void)setInsuranceModel:(LXInsuranceModel *)insuranceModel{
    
    _insuranceModel = insuranceModel;
    
    self.label1.text = insuranceModel.carNum;
    
    
    
    NSString *jqStr = [NSString stringWithFormat:@"交强险 | 结束日期: %@",insuranceModel.compulsoryEndTime];
    self.label2.text = jqStr;
    
    NSString *syStr = [NSString stringWithFormat:@"商业险 | 结束日期: %@",insuranceModel.businessEndTime];
    self.label3.text = syStr;
    
    // 交强险 逾期
    if (insuranceModel.compulsoryOverDue<=0) {
        
        
        if (insuranceModel.compulsoryOverDue==0) {
            self.label5.text = @"今日逾期";
        }
        else {
            self.label5.text = [NSString stringWithFormat:@"逾期%@天",@(labs(insuranceModel.compulsoryOverDue))];
        }
        self.label5.textColor = [UIColor colorWithHexString:@"#EA545A"];
        self.label2.textColor = [UIColor colorWithHexString:@"#EA545A"];

    }
    // 交强险 没有逾期
    else if(insuranceModel.compulsoryOverDue>=0){
            
//        NSString *day = [NSString timeBeforeInfoWithString:recordModel.compulsoryEndTime secondTime:[NSString getNowDateWithFormat:@"yyyy-MM-dd"]];
        
        self.label5.text = [NSString stringWithFormat:@"%@天后逾期",@(insuranceModel.compulsoryOverDue)];
        self.label5.textColor = mainColor;

        self.label2.textColor = ColorWithAAAAAA;
        [self.label2 addAttributes:@{NSForegroundColorAttributeName : mainColor} forString:@"交强险"];

        
    }
    
    
    
    // 商业险 逾期
    if (insuranceModel.businessOverDue<=0) {
        
        if (insuranceModel.businessOverDue==0) {
            self.label4.text = @"今日逾期";
        }
        else {
            self.label4.text = [NSString stringWithFormat:@"逾期%@天",@(labs(insuranceModel.businessOverDue))];
        }
        self.label4.textColor = [UIColor colorWithHexString:@"#EA545A"];
        self.label3.textColor = [UIColor colorWithHexString:@"#EA545A"];

    }
    // 商业险 没有逾期
    else if(insuranceModel.businessOverDue>0){
    
//        NSString *day = [NSString timeBeforeInfoWithString:recordModel.businessEndTime secondTime:[NSString getNowDateWithFormat:@"yyyy-MM-dd"]];
    
        self.label4.text = [NSString stringWithFormat:@"%@天后逾期",@(insuranceModel.businessOverDue)];
        self.label4.textColor = mainColor;
        
        self.label3.textColor = ColorWithAAAAAA;
        [self.label3 addAttributes:@{NSForegroundColorAttributeName : mainColor} forString:@"商业险"];
        
    }
    self.label6.hidden = YES;
   
}

// 维修记录
- (void)setRepairModel:(LXRepairModel *)repairModel{
    _repairModel = repairModel;
    
    self.label1.text = repairModel.carNum;
    self.label1.textColor = Color333;
    
    self.label2.text = [NSString stringWithFormat:@"进厂日期: %@ | 出厂日期: %@",repairModel.intoTime, repairModel.outTime];
    self.label2.textColor = ColorWithAAAAAA;
    self.label2.width = kScreenWidth - 30;
    
    
    self.label3.text = [NSString stringWithFormat:@"负责人: %@",repairModel.chargeName];
    self.label3.textColor = Color333;
    
    
    NSString *amount = [NSString stringWithFormat:@"%.2lf",[repairModel.repairAmount doubleValue]];
    self.label4.text = [NSString stringWithFormat:@"金额%@元",amount];
    self.label4.textColor = Color333;
    [self.label4 addAttributes:@{NSForegroundColorAttributeName : [UIColor colorWithHexString:@"#EA545A"]} forString:[NSString stringWithFormat:@"%@",amount]];
    
    self.label5.hidden = YES;

    if (repairModel.repairStatus == 1) {
        self.label6.text = @"维修中";
        self.label6.textColor = mainColor;
    }
    else {
        self.label6.text = @"已完成";
        self.label6.textColor = Color999;
    }
    
    
    
    
}


// 年检记录
- (void)setYearCheckModel:(LXYearCheckModel *)yearCheckModel{
    
    _yearCheckModel = yearCheckModel;
    
    self.label1.text = yearCheckModel.carNum;
    self.label1.textColor = Color333;
    
    self.label2.text = [NSString stringWithFormat:@"年检日期: %@ | 下次年检: %@",yearCheckModel.currentInspectTime,yearCheckModel.nextInspectTime];
    self.label2.textColor = ColorWithAAAAAA;
    self.label2.width = kScreenWidth - 30;

    
    self.label3.text = [NSString stringWithFormat:@"负责人: %@", yearCheckModel.chargeName];
    self.label3.textColor = Color333;
    
    NSString *amount = [NSString stringWithFormat:@"%.2lf",[yearCheckModel.amount doubleValue]];
    self.label4.text = [NSString stringWithFormat:@"金额%@元",amount];
    self.label4.textColor = Color333;
    [self.label4 addAttributes:@{NSForegroundColorAttributeName : [UIColor colorWithHexString:@"#EA545A"]} forString:[NSString stringWithFormat:@"%@",amount]];
    
    
    self.label5.hidden = YES;
    
    // 逾期
    if (yearCheckModel.nextInspectTimeOverDue<=0) {
        if (yearCheckModel.nextInspectTimeOverDue==0) {
            self.label6.text = @"今日逾期";
        }
        else {
            self.label6.text = [NSString stringWithFormat:@"逾期%@天",@(labs(yearCheckModel.nextInspectTimeOverDue))];
        }
        self.label6.textColor = [UIColor colorWithHexString:@"#EA545A"];

    }
    // 没有逾期
    else if(yearCheckModel.nextInspectTimeOverDue>=0){
        self.label6.text = [NSString stringWithFormat:@"%@天后逾期",@(yearCheckModel.nextInspectTimeOverDue)];
        self.label6.textColor = mainColor;
        
    }
    
    
    
}

// 保养记录
- (void)setMainTainModel:(LXMainTainModel *)mainTainModel{
    
    _mainTainModel = mainTainModel;
    
    self.label1.text = mainTainModel.carNum;
    self.label1.textColor = Color333;
    
    self.label2.text = [NSString stringWithFormat:@"保养日期: %@ | 下次保养: %@",mainTainModel.intoTime,mainTainModel.nextMaintainTime];
    self.label2.textColor = ColorWithAAAAAA;
    self.label2.width = kScreenWidth - 30;


    self.label3.text = [NSString stringWithFormat:@"负责人: %@", mainTainModel.chargeName];
    self.label3.textColor = Color333;

    NSString *amount = [NSString stringWithFormat:@"%.2lf",[mainTainModel.repairAmount doubleValue]];
    self.label4.text = [NSString stringWithFormat:@"金额%@元",amount];
    self.label4.textColor = Color333;
    [self.label4 addAttributes:@{NSForegroundColorAttributeName : [UIColor colorWithHexString:@"#EA545A"]} forString:[NSString stringWithFormat:@"%@",amount]];


    self.label5.hidden = YES;

    self.label6.text = [NSString stringWithFormat:@"%@Km",mainTainModel.currentMiles];
    self.label6.textColor = mainColor;
    
    
}





- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}



@end
